package com.nanyang.tms.common.util;

import com.nanyang.common.core.dict.CommonEnum;
import com.nanyang.tms.common.exception.TmsManagerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;




public class TmsExceptionUtil {
	private static final Logger logger =LoggerFactory.getLogger(TmsExceptionUtil.class);
 
	  public static RuntimeException wrapException (Exception e) {
		  if(e instanceof TmsManagerException){
			  logger.error("异常发生错误码：{}，错误信息：{}",((TmsManagerException) e).getCode(),((TmsManagerException) e).getMessage());
			  return (TmsManagerException)e;
		  }else{
			    logger.error("异常发生错误码：{} ，错误信息：{}", CommonEnum.SYSTEM_EXCEPTION.getCode(), CommonEnum.SYSTEM_EXCEPTION.getMessage(), e);
				return  new TmsManagerException(CommonEnum.SYSTEM_EXCEPTION.getCode(),CommonEnum.SYSTEM_EXCEPTION.getMessage(),e.getMessage());
		  }
		  
		  
	    
	  }
}
